<#import "/macro.ftl" as m>
<@m.page_header title='APP底部导航图标zip包上传' />
<script type="text/javascript" src="/assets/js/md5.js"></script>
<script type="text/javascript" src="/assets/js/hejiauploadimage.js"></script>

<div id="page-content-wrapper">
    <div id="page-title">
        <h3>APP底部导航图标zip包上传</h3>
    </div>

    <div id="page-content">
        <div class="row">
            <div class="col-md-12 mrg20A">
                <label class="font-blue font-size-35">iOS</label>
            </div>
        </div>

        <div id="iOSDiv">


            <div class="row">
                <div class="col-md-4">
                    <div class="form-row">
                        <div class="form-label col-md-4">
                            <label id="startTime">开始时间：</label>
                        </div>
                        <div class="form-input col-md-6">
                            <input id="startTime" name="startTime" value="${iOSstartTime}" data-required="true"
                                   onClick="WdatePicker({isShowWeek:true,dateFmt:'yyyy-MM-dd HH:mm:ss'})" type="text">
                        </div>
                    </div>
                </div>
                <div class="col-md-4">
                    <div class="form-row">
                        <div class="form-label col-md-4">
                            <label id="endTime">结束时间：</label>
                        </div>
                        <div class="form-input col-md-6">
                            <input id="endTime" name="endTime" value="${iOSendTime}" data-required="true"
                                   onClick="WdatePicker({isShowWeek:true,dateFmt:'yyyy-MM-dd HH:mm:ss'})" type="text">
                        </div>
                    </div>
                </div>
                <div class="col-md-4">
                    <div class="form-row">
                        <div class="form-label col-md-4">
                            <label id="endTime">包名：</label>
                        </div>
                        <div class="form-input col-md-6">
                            <input id="name" name="name" value="${iOSname}" data-required="true" type="text">
                        </div>
                    </div>
                </div>
            </div>

            <div class="row">
                    <div class="row">
                        <div class="col-md-4">
                            <div class="form-label col-md-4">
                                <label id="startTime">地址：</label>
                            </div>
                            <div class="form-input col-md-6">

                                <input placeholder="" data-required="true" type="text" name="link" id="iOSNavigation" value="${iOSlink}"/>
                            </div>
                            <div class="form-label col-md-2">
                                <a id="uploadButton" class="btn medium primary-bg radius-all-4">
                                    <span class="button-content">上传导航图标zip</span>
                                </a>
                            </div>
                        </div>

                        <div class="col-md-1"></div>

                        <div class="form-label col-md-2">
                            <a id="iOSbutton" class="btn medium primary-bg radius-all-4">
                                <span class="button-content">确定更新</span>
                            </a>
                        </div>
                    </div>

            </div>

        </div>

        <form id="iosform" action="/navigation/add" method="POST">
            <input type="hidden" name="id" value="${iosParameter.id}"/>
            <input id="iOSValue" type="hidden" name="value" />
            <input type="hidden" name="code" value="iOS"/>
            <input type="hidden" name="category" value="Navigation_ICON"/>
        </form>

        <#--==================================================以下安卓================================================================-->
        <form id="androidform" action="/navigation/add" method="POST">
            <input type="hidden" name="id" value="${androidParameter.id}"/>
            <input id="androidValue" type="hidden" name="value" />
            <input type="hidden" name="code" value="Android"/>
            <input type="hidden" name="category" value="Navigation_ICON"/>
        </form>

            <div class="row">
                <div class="col-md-12 mrg20A">
                    <label class="font-blue font-size-35">Android</label>
                </div>
            </div>

        <div id="androidDiv">
            <div class="row">
                <div class="col-md-4">
                    <div class="form-row">
                        <div class="form-label col-md-4">
                            <label id="startTime">开始时间：</label>
                        </div>
                        <div class="form-input col-md-6">
                            <input id="startTime" name="startTime" value="${androidstartTime}" data-required="true"
                                   onClick="WdatePicker({isShowWeek:true,dateFmt:'yyyy-MM-dd HH:mm:ss'})" type="text">
                        </div>
                    </div>
                </div>
                <div class="col-md-4">
                    <div class="form-row">
                        <div class="form-label col-md-4">
                            <label id="endTime">结束时间：</label>
                        </div>
                        <div class="form-input col-md-6">
                            <input id="endTime" name="endTime" value="${androidendTime}" data-required="true"
                                   onClick="WdatePicker({isShowWeek:true,dateFmt:'yyyy-MM-dd HH:mm:ss'})" type="text">
                        </div>
                    </div>
                </div>
                <div class="col-md-4">
                    <div class="form-row">
                        <div class="form-label col-md-4">
                            <label id="endTime">包名：</label>
                        </div>
                        <div class="form-input col-md-6">
                            <input id="name" name="name" value="${androidname}" data-required="true" type="text">
                        </div>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="form-input col-md-8">
                    <div class="row">
                        <div class="col-md-4">

                            <input placeholder="" data-required="true" type="text" name="link" id="iOSBanner" value="${androidlink}"/>
                        </div>
                        <div class="form-label col-md-2">
                            <a id="uploadButton1" class="btn medium primary-bg radius-all-4">
                                <span class="button-content">上传导航图标zip</span>
                            </a>
                        </div>
                        <div class="col-md-1"></div>

                        <div class="form-label col-md-2">
                            <a id="androidButton" class="btn medium primary-bg radius-all-4">
                                <span class="button-content">确定更新</span>
                            </a>
                        </div>
                    </div>

                </div>

            </div>
        </div>
    </div>

</div>

<script>
    $(function() {
    <#if msg!=null>
        $.jGrowl("${msg}", {sticky:!1,position:'bottom-right',theme:'bg-green'});
    </#if>

        $("#uploadButton").click(function () {
            $(this).addMyUpload("navigationzip/", 2);
        });

        $("#uploadButton1").click(function () {
            $(this).addMyUpload("navigationzip/", 2);
        });

        $("#iOSbutton").click(function () {
            $("#iOSValue").val(getTV("iOSDiv"));

            $('#iosform').parsley('validate');
            $('#iosform').trigger('submit');
        });

        $("#androidButton").click(function () {

            $("#androidValue").val(getTV("androidDiv"));

            $('#androidform').parsley('validate');
            $('#androidform').trigger('submit');
        });


        //在div里面取input 的值循环成json
        function getTV(eleID) {
            var eles = $("#" + eleID + " input[type!=file]");
            var value = "{";
            for (var i = 0; eles != null && i < eles.length; i++) {
                if (i > 0) {
                    value += ',';
                }
                value += '"' + eles[i].name + '":"' + eles[i].value + '"';
            }
            value += "}";
            return value;
        }
    })
</script>